package org.javabrains.koushik.hibernate;


import java.util.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;





import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.javabrains.koushik.dto.EmpDet;

public class EmpTest {
	
	
	public static void main(String args[]) throws ParseException{
		
	
		EmpDet ed = new EmpDet();
		
		ed.setEmpid(001);
		ed.setEmpname("tester");
		ed.setDOB("23-02-2000");
		ed.setCtc(123456789);
		ed.setHeight(55.88f);
		ed.setSalary(25555.2222);
		
		String datestring = "23-02-2015";
		DateFormat format = new SimpleDateFormat("dd-MM-YYYY");
		Date dt =  format.parse(datestring);
		
		
		ed.setDOJ(dt);
		
		
		//persist the object
		
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		Session ss = sf.openSession();
		ss.beginTransaction();
		ss.save(ed);
		ss.getTransaction().commit();
		
		
		
		
		
		
	}//psvm

}
